<?php

class Zend_View_Helper_Showiconsforagents extends Zend_View_Helper_Abstract {

    private $desc = array(
        'agent' => array('visible' => array( '0' => 'Agent is hidden',
                                             '1' => 'Agent can be used')),
        'hub' => array('public' => array(    '0' => 'Hub can be seen only locally',
                                             '1' => 'Visible by clients and in gateway'),
                       'active' => array(    '0' => 'Hub is inactive',
                                             '1' => 'Hub is active')),
        'device' => array('public' => array( '0' => 'Device can be seen only locally',
                                             '1' => 'Visible by clients and in gateway'),
                          'active' => array( '0' => 'Device is inactive',
                                             '1' => 'Device is active'),
                          'static' => array( '0' => 'Device\'s value can be changed',
                                             '1' => 'Device\'s value is read only')),
        );
    
    public function showiconsforagents($type, $value, $lock = 0, $target = "agent") {
        return $this->generateIcon($type, $value, $lock, $target);
    }

    public function generateIcon($type = "", $value, $lock, $target) {
        if ($type != "") {
            if($type == "visible") {
                if($value == 1) {
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/application_add.png\" alt=\"visible\" title=\"\" width=\"16\" height=\"16\" /></a>\n";
                } else if ($value == 0){
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/application.png\" alt=\"not visible\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                    
                }
            } else if($type == "public") {
                if($value == 1) {
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/eye.png\" alt=\"public access\" title=\"\" width=\"16\" height=\"16\" /></a>\n";
                } else if ($value == 0){
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/stop.png\" alt=\"private\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                    
                }
            } else if($type == "active") {
                if($value == 1) {
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/flag_green.png\" alt=\"active\" title=\"\" width=\"16\" height=\"16\" /></a>\n";
                } else if ($value == 0){
                    $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/flag_red.png\" alt=\"inactive\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                    
                }
            } else if($type == "static") {
                if($value == 1) {
                    if($lock) {
                        $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "<br><strong>This attribute can't be amended by user</strong>\"><img src=\"/images/icons/shield_delete.png\" alt=\"static\" title=\"\" width=\"16\" height=\"16\" /></a>\n";
                    } else {
                        $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/shield.png\" alt=\"static\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                        
                    }
                } else if ($value == 0){
                    if($lock) {
                        $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "<br><strong>This attribute can't be amended by user</strong>\"><img src=\"/images/icons/shield_go_delete.png\" alt=\"dynamic\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                    
                    } else {
                        $returnString = "<a title=\"" . $this->desc[$target][$type][$value] . "\"><img src=\"/images/icons/shield_go.png\" alt=\"dynamic\" title=\"\" width=\"16\" height=\"16\" /></a>\n";                                            
                    }                        
                }
            }
        } else {
            $returnString = "dfsfs";
        }
        return $returnString;
    }

}
?>